﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OSGeo.MapGuide
{
    /// <summary>
    /// Defines a feature source that participates in a feature join
    /// </summary>
    public class MgJoinPrimaryFeatureSource
    {
        /// <summary>
        /// Creates a new instance of <see cref="MgJoinFeatureSource"/>
        /// </summary>
        /// <param name="featureSourceId"></param>
        /// <param name="schemaName"></param>
        /// <param name="className"></param>
        public MgJoinPrimaryFeatureSource(MgResourceIdentifier featureSourceId,
                                          string schemaName,
                                          string className)
        {
            if (null == featureSourceId)
                throw new ArgumentNullException("featureSourceId");

            if (featureSourceId.GetResourceType() != MgResourceType.FeatureSource)
                throw new ArgumentException("Not a feature source", "featureSourceId");

            if (string.IsNullOrEmpty(schemaName))
                throw new ArgumentNullException("schemaName");

            if (string.IsNullOrEmpty(className))
                throw new ArgumentNullException("className");

            this.FeatureSource = featureSourceId;
            this.SchemaName = schemaName;
            this.ClassName = className;
        }

        /// <summary>
        /// Gets the feature source resource id
        /// </summary>
        public MgResourceIdentifier FeatureSource { get; private set; }

        /// <summary>
        /// Gets the schema name
        /// </summary>
        public string SchemaName { get; private set; }

        /// <summary>
        /// Gets the class name
        /// </summary>
        public string ClassName { get; private set; }

        /// <summary>
        /// Gets the qualified class name
        /// </summary>
        public string QualifiedClassName
        {
            get
            {
                return SchemaName + ":" + ClassName;
            }
        }
    }
}
